<template>
	<view class="page_bg pos_rel">
		<image src="https://www.worldintek.com:39011/yaolexue-service/icon_dati_bg.png" class="imgbg"></image>
		<view class="pos_rel padd-top30">
			<view @click="clickJunmpSpec(item)" v-for="(item,index) in list" :key="index" class="list-item">
				<view class="name">
					{{item.title}}
				</view>
				<view class="time mar-top20 line-height100">
					{{item.startTime}}
				</view>
				<view class="btn flex align-center justify-center">
					开始答题
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list:[],
				noMore:false,
				page:{
					page:1,
					limit:20
				}
			};
		},
		onLoad() {
			this.getList()
		},
		onReachBottom() {
			if(!this.noMore)
				this.getList()
		},
		onPullDownRefresh() {
			this.noMore = false
			this.page.page = 1
			this.getList()
		},
		methods:{
			getList(){
				this.$http.get('/yaolexue-service-portal/exam/subjects/page',{
					...this.page
				}).then(res => {
					if(res.code == 200){
						if(this.page.page == 1) this.list = []
						this.list = [...this.list,...res.data.items]
						this.noMore = this.list.length >= res.data.total
						this.page.page++
					}
				})
			},
			clickJunmpSpec(item){
				uni.navigateTo({
					url:`/subPages/specialAnswer/specialAnswer?type=2&subjectId=${item.id}&status=${item.status}&isAnalysisShow=${item.finishedCnt >= item.totalCnt ? 1 : 0}`
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.imgbg{
		width: 100%;
		height: 1081rpx;
		position: absolute;
		top: 0;
	}
	.list-item{
		width: 651rpx;
		background: #FFFFFF;
		border-radius: 16rpx;
		margin: 0 auto 20rpx auto;
		padding: 21rpx 27rpx 19rpx 27rpx;
		.name{
			font-size: 28rpx;
			font-family: Source Han Sans CN;
			font-weight: 500;
			color: #333333;
			line-height: 50rpx;
		}
		.time{
			font-size: 24rpx;
			font-family: Source Han Sans CN;
			font-weight: 400;
			color: #999999;
		}
		.btn{
			width: 138rpx;
			height: 51rpx;
			background: #FA312A;
			border-radius: 10rpx;
			font-size: 24rpx;
			font-family: Source Han Sans CN;
			font-weight: 400;
			color: #FFFFFF;
			margin: 2rpx 0 0 auto;
		}
	}
</style>
